package com.geostart.constructionland.system.controller;


import com.geostar.constructionland.common.entity.logs.mongolog.LogMongoSpt;
import com.geostar.constructionland.common.entity.response.ExtJsAjaxResponse;
import com.geostart.constructionland.system.service.LogMongoFeignClient;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * @author chengan
 * @description mongo日志
 */

@Controller
@RequestMapping(path = "/logMongo")
public class LogMongoController {

    @Autowired
    LogMongoFeignClient logMongoFeignClient;


    @RequestMapping(path = "/profile")
    public String initPage() {
        return "profile/log_mongo";
    }

    @PostMapping("/getMongoLog")
    @ResponseBody
    @ApiOperation(value = "获取日志信息")
    public ExtJsAjaxResponse getMongoLog(@NotBlank(message = "页码不能为空") @RequestParam(value = "page") int pageNo,
                                         @NotBlank(message = "每页数量不能为空") @RequestParam(value = "limit") int pageNum) {
        return logMongoFeignClient.getMongoLog(pageNo, pageNum);
    }

    @PostMapping("/insertMongoLog")
    @ResponseBody
    @ApiOperation(value = "新增Mongo日志")
    public ExtJsAjaxResponse updateMongoLof(LogMongoSpt logMongoSpt) {
        return logMongoFeignClient.addMongoLog(logMongoSpt);
    }

    @ApiOperation(value = "删除Mongo日志")
    @ResponseBody
    @PostMapping("/deleteMongoLog")
    public ExtJsAjaxResponse deleteMongoLog(@RequestParam(value = "id") String id) {
        return logMongoFeignClient.deleteMongoLog(id);
    }


    @ApiOperation(value = "更新Mongo日志")
    @ResponseBody
    @PostMapping("/updateMongoLog")
    public ExtJsAjaxResponse insertAnalyseMapped(LogMongoSpt logMongoSpt) {
        return logMongoFeignClient.updateMongoLog(logMongoSpt);
    }

    @ApiOperation(value = "根据id查找mongo日志信息")
    @ResponseBody
    @GetMapping("/getMongoLogById")
    public ExtJsAjaxResponse getMongoLogById(@RequestParam(value = "mongoId") String mongoId){
        return logMongoFeignClient.getMongoLogById(mongoId);
    }



}
